package cn.iocoder.an.module.mold.dal.mysql.repairaccount;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.repairaccount.RepairAccountDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.repairaccount.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 模具维修申请 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface RepairAccountMapper extends BaseMapperX<RepairAccountDO> {

    default PageResult<RepairAccountDO> selectPage(RepairAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RepairAccountDO>()
                .likeIfPresent(RepairAccountDO::getCode, reqVO.getCode())
                .likeIfPresent(RepairAccountDO::getName, reqVO.getName())
                .eqIfPresent(RepairAccountDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(RepairAccountDO::getFaultId, reqVO.getFaultId())
                .eqIfPresent(RepairAccountDO::getApplicantId, reqVO.getApplicantId())
                .eqIfPresent(RepairAccountDO::getDepartId, reqVO.getDepartId())
                .eqIfPresent(RepairAccountDO::getUrgencyLevel, reqVO.getUrgencyLevel())
                .betweenIfPresent(RepairAccountDO::getFaultTime, reqVO.getFaultTime())
                .betweenIfPresent(RepairAccountDO::getApplicationTime, reqVO.getApplicationTime())
                .eqIfPresent(RepairAccountDO::getFaultDescription, reqVO.getFaultDescription())
                .eqIfPresent(RepairAccountDO::getRepairMethod, reqVO.getRepairMethod())
                .eqIfPresent(RepairAccountDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(RepairAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RepairAccountDO::getId));
    }

    @Delete("DELETE FROM mold_repair_account WHERE id = #{id}")
    int forceDeleteById(@Param("id") Long id);
}